package com.hp.team.bookstore.model.catalog;

import java.net.URL;
import java.util.Collection;
import java.util.HashSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "VENDOR")
public class Vendor extends CatalogItem {

	@Column(name = "URL")
	private URL url;

	@Column(name = "END_POINT")
	private URL endPoint;

	@Column(name = "PORT")
	private int port;

	@OneToMany(mappedBy = "vendor", cascade = CascadeType.ALL)
	private Collection<Product> childProducts = new HashSet<Product>();

	public URL getUrl() {
		return url;
	}

	public URL getEndPoint() {
		return endPoint;
	}

	public int getPort() {
		return port;
	}

	public void setUrl(URL url) {
		this.url = url;
	}

	public void setEndPoint(URL endPoint) {
		this.endPoint = endPoint;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public void setChildProducts(Collection<Product> childProducts) {
		this.childProducts = childProducts;
	}

	public Collection<Product> getChildProducts() {
		return childProducts;
	}

	@Override
	public String toString() {
		return getName();
	}
}
